#include "MOV.h"
#include <iostream>

MOV::MOV(void)
{
}


MOV::~MOV(void)
{
}

void MOV::Load( char* a_FilePath )
{
	FILE* FileHandler = fopen( a_FilePath, "rb" );

	fread( &m_Width, sizeof( m_Width ), 1, FileHandler );
	fread( &m_Height, sizeof( m_Height ), 1, FileHandler );

	for ( int i = 0; i <10; i++ )
	{
		for ( int j = 0; j < 10; j++ )
		{
			fread( &m_IsWalkable[i][j], sizeof( unsigned char ), 1, FileHandler );
			printf( "%i , %i : %u\n", i, j, m_IsWalkable[i][j]);
		}
	}

	fclose( FileHandler );
}

void MOV::Save( char* a_FilePath )
{
	FILE* FileHandler = fopen( a_FilePath, "wb" );

	fwrite( &m_Width, sizeof( m_Width ), 1, FileHandler );
	fwrite( &m_Height, sizeof( m_Height ), 1, FileHandler );

	for ( int i = 0; i < m_Width; i++ )
	{
		for ( int j = 0; j < m_Height; j++ )
		{
			fwrite( &m_IsWalkable[i][j], sizeof( unsigned char ), 1, FileHandler );
		}
	}

	fclose( FileHandler );
}

bool MOV::GetPosition( unsigned int a_X, unsigned int a_Y )
{
	return m_IsWalkable[a_X][a_Y];
}
